/**
 *     This file is part of cesm-ws.
 *
 *     cesm-ws, Web Service for Community Earth System Model
 *
 *     Copyright (c) 2010, Purdue University and/or affilicates or thrid-party contributors as
 *     indicated by the @author tags or express copyright attribution statements
 *     applied by the authors. All third-party contributions are distributed under
 *     license by Purdue University.
 *
 *     cesm-ws is free software: you can redistribute it and/or modify
 *     it under the terms of the GNU General Public License as published by
 *     the Free Software Foundation, either version 3 of the License, or
 *     (at your option) any later version.
 *
 *     This program is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *     GNU General Public License for more details.
 *
 *     You should have received a copy of the GNU Lesser General Public License
 *     along with this distribution.  If not, see <http://www.gnu.org/licenses/>.
 */

package edu.purdue.rcac.cesm.define;

/**
 * This is enumeration of valid values for createCase input field
 * 'componentSet'. This class is written in accordance with 'create_newcase
 * -list' output for CCSM 4.0 scripts.
 * 
 * @author Han Zhang
 * 
 */
public enum ComponentSet {
	/**
	 * Decription: All data model
	 */
	A_PRESENT_DAY("A"),

	/**
	 * Decription: All active components, present day
	 */
	B_2000("B"),

	/**
	 * Decription: All active components, pre-industrial
	 */
	B_1850("B1850"),

	/**
	 * Decription: all active components, pre-industrial, with CN (Carbon
	 * Nitrogen) in CLM <br>
	 * GRID_MATCH: f09_g16, f19_g16 <br>
	 */
	B_1850_CN("B1850CN"),

	/**
	 * Decription: All active components, pre-industrial, with CN (Carbon
	 * Nitrogen) in CLM and super_fast_llnl chem in atm
	 */
	B_1850_CN_CHEM("B1850CNCHM"),

	/**
	 * Decription: All active components, pre-industirial with co2 ramp, with CN
	 * (Carbon Nitrogen) in CLM <br>
	 * GRID_MATCH: f09_g16, f19_g16 <br>
	 */
	B_1850_RAMPCO2_CN("B1850RMCN"),

	/**
	 * Decription: All active components, 1850 to 2000 transient
	 */
	B_1850_2000("B20TR"),

	/**
	 * Decription: All active components, 1850 to 2000 transient, with CN
	 * (Carbon Nitrogen) in CLM <br>
	 * GRID_MATCH: f09_g16 <br>
	 */
	B_1850_2000_CN("B20TRCN"),

	/**
	 * Decription: All active components, 1850 to 2000 transient, with CN
	 * (Carbon Nitrogen) in CLM and super_fast_llnl chem in atm
	 */
	B_1850_2000_CN_CHEM("B20TRCNCHM"),

	/**
	 * Decription: All active components, with trop_mozart
	 */
	B_2000_TROP_MOZART("BMOZ"),

	/**
	 * Decription: all active components, pre-industrial, with waccm
	 */
	B_1850_WACCM("BW1850"),

	/**
	 * Decription: all active components, pre-industrial, with waccm and CN
	 */
	B_1850_WACCM_CN("BW1850CN"),

	/**
	 * Decription: Active ocean model with COREv2 normal year forcing
	 */
	C_NORMAL_YEAR("C"),

	/**
	 * Decription: Active ice model with COREv2 normal year forcing
	 */
	D_NORMAL_YEAR("D"),

	/**
	 * Decription: Fully active cam and ice with som ocean, present day
	 */
	E_2000("E"),

	/**
	 * Decription: Pre-industrial fully active ice and som ocean, with CN
	 */
	E_1850_CN("E1850CN"),

	/**
	 * Decription: Default resoluton independent AMIP is INVALID <br>
	 * GRID_MATCH: f09_f09, f19_f19 <br>
	 */
	F_AMIP("FAMIP"),

	/**
	 * Decription: Pre-industrial cam/clm with prescribed ice/ocn
	 */
	F_1850("F1850"),

	/**
	 * Decription: Stand-alone cam default, prescribed ocn/ice
	 */
	F_2000("F"),

	/**
	 * Decription: Stand-alone cam default, prescribed ocn/ice with CN
	 */
	F_2000_CN("FCN"),

	/**
	 * Decription: 20th Century transient stand-alone cam default, prescribed
	 * ocn/ice, with CN
	 */
	F_1850_2000_CN("F20TRCN"),

	/**
	 * Decription: Pre-industrial cam/clm with prescribed ice/ocn
	 */
	F_WACCM_1850("FW1850"),

	/**
	 * Decription: Coupled ocean ice with COREv2 normal year forcing
	 */
	G_NORMAL_YEAR("G"),

	/**
	 * Decription: Coupled ocean ice slnd
	 */
	H_PRESENT_DAY("H"),

	/**
	 * Decription: Active land model with QIAN atm input data for 2003 and
	 * Satellite phenology (SP), CO2 level and Aerosol deposition for 2000 <br>
	 * GRID_MATCH: f09_g16, f19_g16 <br>
	 */
	I_2000("I"),

	/**
	 * Decription: Active land model with QIAN atm input data for 1948 to 1972
	 * and Satellite phenology (SP), CO2 level and Aerosol deposition for 1850 <br>
	 * GRID_MATCH: f09_g16, f19_g16 <br>
	 */
	I_1850("I1850"),

	/**
	 * Decription: Active land model with QIAN atm input data for 1948 to 2004
	 * and Satellite phenology (SP), CO2 level and Aerosol deposition for 2000 <br>
	 * GRID_MATCH: f09_g16, f19_g16 <br>
	 */
	I_1948_2004("I4804"),

	/**
	 * Decription: Active land model with QIAN atm input data for 1948 to 2004
	 * and transient Satellite phenology (SP), and Aerosol deposition from 1850
	 * to 2000 and 2000 CO2 level <br>
	 * GRID_MATCH: f09_g16, f19_g16 <br>
	 */
	I_1850_2000("I8520"),

	/**
	 * Decription: Active land model with QIAN atm input data for 2003 and CN
	 * (Carbon Nitrogen) biogeochemistry, CO2 level and Aerosol deposition for
	 * 2000 <br>
	 * GRID_MATCH: f09_g16, f19_g16 <br>
	 */
	I_2000_CN("ICN"),

	/**
	 * Decription: Active land model with QIAN atm input data for 1948 to 1972
	 * and CN (Carbon Nitrogen) biogeochemistry, CO2 level and Aerosol
	 * deposition for 1850 <br>
	 * GRID_MATCH: f09_g16, f19_g16 <br>
	 */
	I_1850_CN("I1850CN"),

	/**
	 * Decription: Active land model with QIAN atm input data for 1948 to 2004
	 * and CN (Carbon Nitrogen) biogeochemistry, CO2 level and Aerosol
	 * deposition for 2000 <br>
	 * GRID_MATCH: f09_g16, f19_g16 <br>
	 */
	I_1948_2004_CN("I4804CN"),

	/**
	 * Decription: Active land model with QIAN atm input data for 1948 to 1972
	 * and transient CN (Carbon Nitrogen) biogeochemistry, and Aerosol
	 * deposition from 1850 to 2000 and 2000 CO2 level <br>
	 * GRID_MATCH: f09_g16, f19_g16 <br>
	 */
	I_1850_2000_CN("I8520CN"),

	/**
	 * Decription: All stub models plus xatm
	 */
	S_PRESENT_DAY("S"),

	/**
	 * Decription: All dead model
	 */
	X_PRESENT_DAY("X");

	private String shortName;

	private ComponentSet(String shortName) {
		this.shortName = shortName;
	}

	/**
	 * This method replaces '-' with '_' in input string, and returns a
	 * ComponentSet enum type object if input string matches name or shortName.
	 * 
	 * @param nameOrShortName
	 *            name or short name
	 * @return ComponentSet enum type object
	 * @throws IllegalArgumentException
	 */
	public static ComponentSet fromString(String nameOrShortName)
			throws IllegalArgumentException {
		String name = nameOrShortName.replaceAll("-", "_").toUpperCase();
		for (ComponentSet c : ComponentSet.values()) {
			if (c.shortName.equals(name) || c.name().equals(name)) {
				return c;
			}
		}
		throw new IllegalArgumentException("Can not match '" + nameOrShortName
				+ "' to enum ComponentSet");
	}
}
